
package galcon.visuals.components;

import galcon.utils.Drawable;
import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;

public class Fleet implements Drawable {
	protected ArrayList <Ship>	ships;
	
	public Fleet (int size, Planet source, Planet destination, int ownerID, Color color) {
		this.ships = new ArrayList <Ship> ();
		this.ships.add (new Ship (source, destination, ownerID, color, size));
	}
	
	public void setOwnerID (int ownerID) {
		for (Ship s : ships)
			s.setOwnerID (ownerID);
	}
	
	public void setDestPlanet (Planet destination) {
		for (Ship s : ships)
			s.setDestPlanet (destination);
	}
	
	public int getOwnerID () {
		return ships.get (0).getOwnerID ();
	}
	
	public Planet getDestPlanet () {
		return ships.get (0).getDestPlanet ();
	}
	
	public void step () {
		for (Ship s : ships)
			if (s.step ()) s.setDone ();
	}
	
	public void draw (Graphics g) {
		step ();
		for (Ship s : ships)
			if (!s.isDone ()) s.draw (g);
	}
	
	public boolean hasShips () {
		boolean ok = false;
		for (Ship s : ships)
			if (!s.isDone ()) ok = true;
		return ok;
	}
}
